home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / os2 / bind493a.zip / bin / copyright next >
Text File  |  1993-07-06  |  5KB  |  148 lines

  1. #!/usr/bin/perl
  2.  
  3. # copyright - replace copyright in specified files
  4. # vix 17apr93 [fixed truncation bug; only edit writable files]
  5. # vix 31mar93 [added individual dating per file]
  6. # vix 02feb93 [original, for bind 4.9]
  7.  
  8. ## ++Copyright++
  9. ## -
  10. ## Copyright (c) 
  11. ##    The Regents of the University of California.  All rights reserved.
  12. ## 
  13. ## Redistribution and use in source and binary forms, with or without
  14. ## modification, are permitted provided that the following conditions
  15. ## are met:
  16. ## 1. Redistributions of source code must retain the above copyright
  17. ##    notice, this list of conditions and the following disclaimer.
  18. ## 2. Redistributions in binary form must reproduce the above copyright
  19. ##    notice, this list of conditions and the following disclaimer in the
  20. ##    documentation and/or other materials provided with the distribution.
  21. ## 3. All advertising materials mentioning features or use of this software
  22. ##    must display the following acknowledgement:
  23. ##     This product includes software developed by the University of
  24. ##     California, Berkeley and its contributors.
  25. ## 4. Neither the name of the University nor the names of its contributors
  26. ##    may be used to endorse or promote products derived from this software
  27. ##    without specific prior written permission.
  28. ## 
  29. ## THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  30. ## ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  31. ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  32. ## ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  33. ## FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  34. ## DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  35. ## OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  36. ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  37. ## LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  38. ## OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  39. ## SUCH DAMAGE.
  40. ## -
  41. ## Portions Copyright (c) 1993 by Digital Equipment Corporation.
  42. ## 
  43. ## Permission to use, copy, modify, and distribute this software for any
  44. ## purpose with or without fee is hereby granted, provided that the above
  45. ## copyright notice and this permission notice appear in all copies, and that
  46. ## the name of Digital Equipment Corporation not be used in advertising or
  47. ## publicity pertaining to distribution of the document or software without
  48. ## specific, written prior permission.
  49. ## 
  50. ## THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
  51. ## WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
  52. ## OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
  53. ## CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  54. ## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  55. ## PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
  56. ## ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  57. ## SOFTWARE.
  58. ## -
  59. ## --Copyright--
  60.  
  61. $BeginMarker = '\+\+Copyright\+\+';
  62. $EndMarker = '\-\-Copyright\-\-';
  63. @Copyright = <STDIN>;
  64. print STDERR "copyright from standard input is $#Copyright lines\n";
  65.  
  66. foreach (@ARGV) {
  67.     ©right($_);
  68. }
  69.  
  70. exit 0;
  71.  
  72. sub copyright {
  73.     local($file) = @_;
  74.     local($_, $found, $indent, $in, @file);
  75.  
  76.     if (! -w $file) {
  77.         print STDERR "$file: not writable\n";
  78.         return;
  79.     }
  80.     if (!open(file, "+<$file")) {
  81.         print STDERR "$file: $!\n";
  82.         return;
  83.     }
  84.     $found = 0;
  85.     $in = 0;
  86.     while (<file>) {
  87.         if (/$BeginMarker/o) {
  88.             if ($in) {
  89.                 print STDERR
  90.                   "$file: nested '$BeginMarker'\n";
  91.                 return;
  92.             }
  93.             $indent = $`;
  94.             $dates = $';
  95.             $dates =~ s/^\s+//;
  96.             $dates =~ s/\s+$//;
  97.             $found++;
  98.             $in = 1;
  99.             push(@file, $_);
  100.             foreach (@Copyright) {
  101.                 if (/XYZZY/o) {
  102.                     push(@file, $indent.$`.$dates.$');
  103.                 } else {
  104.                     push(@file, $indent.$_);
  105.                 }
  106.             }
  107.         } elsif (/$EndMarker/o) {
  108.             if (!$in) {
  109.                 print STDERR
  110.                   "$file: mismatched '$EndMarker'\n";
  111.                 return;
  112.             }
  113.             if ($` ne $indent) {
  114.                 print STDERR
  115.                   "$file: indent differs: '$`' vs '$indent'\n";
  116.                 return;
  117.             }
  118.             push(@file, $_);
  119.             $in = 0;
  120.         } else {
  121.             push(@file, $_) unless $in;
  122.         }
  123.     }
  124.     if ($in) {
  125.         print STDERR
  126.           "$file: mismatched '$BeginMarker'\n";
  127.         return;
  128.     }
  129.     if (!$found) {
  130.         print STDERR
  131.           "$file: no '$BeginMarker' or '$EndMarker' found\n";
  132.         return;
  133.     }
  134.     print STDERR "$file: $found copyrights found\n";
  135.     if (!seek(file, 0, 0)) {
  136.         print STDERR
  137.           "$file: seek(f,0,0): $!";
  138.         return;
  139.     }
  140.     print file @file;
  141.     truncate(file, tell(file));
  142.     if (!close(file)) {
  143.         print STDERR
  144.           "$file: close(f): $! (may be corrupt now)\n";
  145.         return;
  146.     }
  147. }
  148.